package com.nbicc.service.modular.dp.panel.service;

import com.nbicc.core.common.RequestPageObj;
import com.nbicc.core.common.ResponseUtil;
import com.nbicc.db.modular.dp.panel.mapper.PanelMapper;
import com.nbicc.db.modular.dp.panel.model.Panel;
import com.nbicc.service.parent.serivce.BaseSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import java.util.Map;

/**
 * @Author: lilingyan
 */
@Service
public class PanelService extends BaseSerivce {

    @Autowired
    private PanelMapper panelMapper;

    public ResponseEntity<ModelMap> selectBySerialNum(String serialNum) {
        return ResponseUtil.ok(panelMapper.selectBySerialNum(serialNum));
    }

    public ResponseEntity<ModelMap> find(RequestPageObj<Map<String, Object>> requestPageObj) {
        setPageHelper(requestPageObj);
        return ResponseUtil.ok(panelMapper.selectByObject(requestPageObj.getData()));
    }

    public ResponseEntity<ModelMap> insert(Panel panel) {
        panelMapper.insert(panel);
        return ResponseUtil.ok(panel);
    }

    public ResponseEntity<ModelMap> updateBySerialNum(Panel panel) {
        panelMapper.updateBySerialNum(panel);
        return ResponseUtil.ok();
    }

    public ResponseEntity<ModelMap> deleteBySerialNum(String serialNum) {
        panelMapper.deleteBySerialNum(serialNum);
        return ResponseUtil.ok();
    }
}
